#use "test10_parser.ml";;

(* debug := true;; *)

let rec post_string s i p = (
	let length = String.length s in
	if i >= length then (
		post (length + 1) '\x1a' p
	) else (
		let p = post (i + 1) s.[i] p in
		post_string s (i + 1) p
	)
);;

let p = create ();;
let p = post_string "S(i1" 0 p;;

flush stderr;;

if accepted p then (
	begin match result p with
	| Some (Subunit (Some 'S', Some '(', Some (Simple_name (Some (Identifier_name (Some 'i')))), None,
		Some (Procedure_unit (None, Some (Aaa (None, Some '1')))))) ->
		begin match errors p with
		| [4, Expected_structured_name;
			4, Expected ['P'];
			4, Expected [')']] ->
			print_string "OK.\n";
		| _ ->
			raise (Failure "BAD ERRORS DETECTED!!")
		end
	| _ ->
		raise (Failure "BAD RESULT!!")
	end
) else (
	raise (Failure "NOT ACCEPTED!!")
);;
